Ext.namespace('Wlanauth');

Wlanauth.BaseWindow=Ext.extend(Ext.Window,{
	width:500,
	formType:null,
	constructor:function(config){
		Ext.apply(this,config);
	      
        Wlanauth.BaseWindow.superclass.constructor.call(this,{
    		frame:true,
    		border:false,
    	    padding:2,
    	    resizable:false,
    	    closeAction:'hide',
    	    items:[{xtype:this.formType}],
    	    keys:[{key: Ext.EventObject.ENTER,handler:this.doOkHandler,scope:this}],
    	    buttons:[{text:'确定',handler:this.doOkHandler,scope:this},
    	              {text:'取消',handler:this.doCancelHandler,scope:this}]
         });
         var formPanel = this.items.itemAt(0);
         formPanel.on('actionSuccess',this.onFormActionSuccess,this);
      },
      onFormActionSuccess:function(form,action){
      	form.reset();
     	this.hide();
     	Ext.Msg.alert('提示','操作成功,数据已保存!');
      },
      doOkHandler:function(){
 		var formPanel = this.items.itemAt(0);
 		formPanel.doSubmit();
      },
      doCancelHandler:function(){
		this.items.itemAt(0).getForm().reset();
    	this.hide();
    	  
      },
      setMode:function(status){
      	if(this.initTitle==null)this.initTitle = this.title;
      	var formPanel = this.items.itemAt(0);
      	formPanel.setMode(status);
      	switch(status){
      		case 'create':
      			this.setTitle(this.initTitle+'<font color="#0000FF">>></font>新增');
      			break;
      		case 'update':
      			this.setTitle(this.initTitle+'<font color="#0000FF">>></font>修改');
      			break;
      		}
      },
      loadDataById:function(id){
      	var formPanel = this.items.itemAt(0);
 		formPanel.loadDataById(id);
      }
	
});